
<!doctype html>
<html lang="en" class="no-js">
  <head>
    
      <meta charset="utf-8">
      <meta name="viewport" content="width=device-width,initial-scale=1">
      
      
      
      
      
      <link rel="icon" href="../../../assets/images/favicon.png">
      <meta name="generator" content="mkdocs-1.4.3, mkdocs-material-9.1.19">
    
    
      
        <title>Treating Java code as a model in Epsilon - Epsilon</title>
      
    
    
      <link rel="stylesheet" href="../../../assets/stylesheets/main.eebd395e.min.css">
      
        
        <link rel="stylesheet" href="../../../assets/stylesheets/palette.ecc896b0.min.css">
      
      

    
    
    
      
        
        
        <link rel="preconnect" href="https://fonts.gstatic.com" crossorigin>
        <link rel="stylesheet" href="https://fonts.googleapis.com/css?family=Roboto:300,300i,400,400i,700,700i%7CRoboto+Mono:400,400i,700,700i&display=fallback">
        <style>:root{--md-text-font:"Roboto";--md-code-font:"Roboto Mono"}</style>
      
    
    
      <link rel="stylesheet" href="../../../assets/stylesheets/mermaid.css">
    
      <link rel="stylesheet" href="../../../assets/javascript/google-code-prettify/prettify.css">
    
      <link rel="stylesheet" href="https://unpkg.com/mermaid@8.5.1/dist/mermaid.css">
    
      <link rel="stylesheet" href="../../../assets/stylesheets/slick.css">
    
      <link rel="stylesheet" href="../../../assets/stylesheets/slick-theme.css">
    
      <link rel="stylesheet" href="../../../assets/stylesheets/extra.css">
    
    <script>__md_scope=new URL("../../..",location),__md_hash=e=>[...e].reduce((e,_)=>(e<<5)-e+_.charCodeAt(0),0),__md_get=(e,_=localStorage,t=__md_scope)=>JSON.parse(_.getItem(t.pathname+"."+e)),__md_set=(e,_,t=localStorage,a=__md_scope)=>{try{t.setItem(a.pathname+"."+e,JSON.stringify(_))}catch(e){}}</script>
    
      
<script>
  window.ga = window.ga || function() {
    (ga.q = ga.q || []).push(arguments)
  }
  ga.l = +new Date
  /* Setup integration and send page view */
  ga("create", "UA-184785655-1", "auto")
  ga("set", "anonymizeIp", true)
  ga("send", "pageview")
  /* Register handler to log search on blur */
  document.addEventListener("DOMContentLoaded", () => {
    if (document.forms.search) {
      var query = document.forms.search.query
      query.addEventListener("blur", function() {
        if (this.value) {
          var path = document.location.pathname;
          ga("send", "pageview", path + "?q=" + this.value)
        }
      })
    }
  })
</script>
<script async src="https://www.google-analytics.com/analytics.js"></script>
    
    
    
  </head>
  
  
    
    
    
    
    
    <body dir="ltr" data-md-color-scheme="default" data-md-color-primary="black" data-md-color-accent="orange">
  
    
    
    <input class="md-toggle" data-md-toggle="drawer" type="checkbox" id="__drawer" autocomplete="off">
    <input class="md-toggle" data-md-toggle="search" type="checkbox" id="__search" autocomplete="off">
    <label class="md-overlay" for="__drawer"></label>
    <div data-md-component="skip">
      
        
        <a href="#treating-java-code-as-a-model-in-epsilon" class="md-skip">
          Skip to content
        </a>
      
    </div>
    <div data-md-component="announce">
      
    </div>
    
    
      

  

<header class="md-header md-header--shadow" data-md-component="header">
  <nav class="md-header__inner md-grid" aria-label="Header">
    <a href="../../.." title="Epsilon" class="md-header__button md-logo" aria-label="Epsilon" data-md-component="logo">
      
  <img src="../../../assets/images/epsilon-white-background.png" alt="logo">

    </a>
    <label class="md-header__button md-icon" for="__drawer">
      <svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24"><path d="M3 6h18v2H3V6m0 5h18v2H3v-2m0 5h18v2H3v-2Z"/></svg>
    </label>
    <div class="md-header__title" data-md-component="header-title">
      <div class="md-header__ellipsis">
        <div class="md-header__topic">
          <span class="md-ellipsis">
            Epsilon
          </span>
        </div>
        <div class="md-header__topic" data-md-component="header-topic">
          <span class="md-ellipsis">
            
              Treating Java code as a model in Epsilon
            
          </span>
        </div>
      </div>
    </div>
    
      
    
    
    
      <label class="md-header__button md-icon" for="__search">
        <svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24"><path d="M9.5 3A6.5 6.5 0 0 1 16 9.5c0 1.61-.59 3.09-1.56 4.23l.27.27h.79l5 5-1.5 1.5-5-5v-.79l-.27-.27A6.516 6.516 0 0 1 9.5 16 6.5 6.5 0 0 1 3 9.5 6.5 6.5 0 0 1 9.5 3m0 2C7 5 5 7 5 9.5S7 14 9.5 14 14 12 14 9.5 12 5 9.5 5Z"/></svg>
      </label>
      <div class="md-search" data-md-component="search" role="dialog">
  <label class="md-search__overlay" for="__search"></label>
  <div class="md-search__inner" role="search">
    <form class="md-search__form" name="search">
      <input type="text" class="md-search__input" name="query" aria-label="Search" placeholder="Search" autocapitalize="off" autocorrect="off" autocomplete="off" spellcheck="false" data-md-component="search-query" required>
      <label class="md-search__icon md-icon" for="__search">
        <svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24"><path d="M9.5 3A6.5 6.5 0 0 1 16 9.5c0 1.61-.59 3.09-1.56 4.23l.27.27h.79l5 5-1.5 1.5-5-5v-.79l-.27-.27A6.516 6.516 0 0 1 9.5 16 6.5 6.5 0 0 1 3 9.5 6.5 6.5 0 0 1 9.5 3m0 2C7 5 5 7 5 9.5S7 14 9.5 14 14 12 14 9.5 12 5 9.5 5Z"/></svg>
        <svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24"><path d="M20 11v2H8l5.5 5.5-1.42 1.42L4.16 12l7.92-7.92L13.5 5.5 8 11h12Z"/></svg>
      </label>
      <nav class="md-search__options" aria-label="Search">
        
        <button type="reset" class="md-search__icon md-icon" title="Clear" aria-label="Clear" tabindex="-1">
          <svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24"><path d="M19 6.41 17.59 5 12 10.59 6.41 5 5 6.41 10.59 12 5 17.59 6.41 19 12 13.41 17.59 19 19 17.59 13.41 12 19 6.41Z"/></svg>
        </button>
      </nav>
      
    </form>
    <div class="md-search__output">
      <div class="md-search__scrollwrap" data-md-scrollfix>
        <div class="md-search-result" data-md-component="search-result">
          <div class="md-search-result__meta">
            Initializing search
          </div>
          <ol class="md-search-result__list" role="presentation"></ol>
        </div>
      </div>
    </div>
  </div>
</div>
    
    
      <div class="md-header__source">
        <a href="https://github.com/eclipse/epsilon" title="Go to repository" class="md-source" data-md-component="source">
  <div class="md-source__icon md-icon">
    
    <svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 448 512"><!--! Font Awesome Free 6.4.0 by @fontawesome - https://fontawesome.com License - https://fontawesome.com/license/free (Icons: CC BY 4.0, Fonts: SIL OFL 1.1, Code: MIT License) Copyright 2023 Fonticons, Inc.--><path d="M439.55 236.05 244 40.45a28.87 28.87 0 0 0-40.81 0l-40.66 40.63 51.52 51.52c27.06-9.14 52.68 16.77 43.39 43.68l49.66 49.66c34.23-11.8 61.18 31 35.47 56.69-26.49 26.49-70.21-2.87-56-37.34L240.22 199v121.85c25.3 12.54 22.26 41.85 9.08 55a34.34 34.34 0 0 1-48.55 0c-17.57-17.6-11.07-46.91 11.25-56v-123c-20.8-8.51-24.6-30.74-18.64-45L142.57 101 8.45 235.14a28.86 28.86 0 0 0 0 40.81l195.61 195.6a28.86 28.86 0 0 0 40.8 0l194.69-194.69a28.86 28.86 0 0 0 0-40.81z"/></svg>
  </div>
  <div class="md-source__repository">
    Epsilon @ GitHub
  </div>
</a>
      </div>
    
  </nav>
  
</header>
    
    <div class="md-container" data-md-component="container">
      
      
        
          
        
      
      <main class="md-main" data-md-component="main">
        <div class="md-main__inner md-grid">
          
            
              
              <div class="md-sidebar md-sidebar--primary" data-md-component="sidebar" data-md-type="navigation" >
                <div class="md-sidebar__scrollwrap">
                  <div class="md-sidebar__inner">
                    


<nav class="md-nav md-nav--primary" aria-label="Navigation" data-md-level="0">
  <label class="md-nav__title" for="__drawer">
    <a href="../../.." title="Epsilon" class="md-nav__button md-logo" aria-label="Epsilon" data-md-component="logo">
      
  <img src="../../../assets/images/epsilon-white-background.png" alt="logo">

    </a>
    Epsilon
  </label>
  
    <div class="md-nav__source">
      <a href="https://github.com/eclipse/epsilon" title="Go to repository" class="md-source" data-md-component="source">
  <div class="md-source__icon md-icon">
    
    <svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 448 512"><!--! Font Awesome Free 6.4.0 by @fontawesome - https://fontawesome.com License - https://fontawesome.com/license/free (Icons: CC BY 4.0, Fonts: SIL OFL 1.1, Code: MIT License) Copyright 2023 Fonticons, Inc.--><path d="M439.55 236.05 244 40.45a28.87 28.87 0 0 0-40.81 0l-40.66 40.63 51.52 51.52c27.06-9.14 52.68 16.77 43.39 43.68l49.66 49.66c34.23-11.8 61.18 31 35.47 56.69-26.49 26.49-70.21-2.87-56-37.34L240.22 199v121.85c25.3 12.54 22.26 41.85 9.08 55a34.34 34.34 0 0 1-48.55 0c-17.57-17.6-11.07-46.91 11.25-56v-123c-20.8-8.51-24.6-30.74-18.64-45L142.57 101 8.45 235.14a28.86 28.86 0 0 0 0 40.81l195.61 195.6a28.86 28.86 0 0 0 40.8 0l194.69-194.69a28.86 28.86 0 0 0 0-40.81z"/></svg>
  </div>
  <div class="md-source__repository">
    Epsilon @ GitHub
  </div>
</a>
    </div>
  
  <ul class="md-nav__list" data-md-scrollfix>
    
      
      
      

  
  
  
    <li class="md-nav__item">
      <a href="../../.." class="md-nav__link">
        Home
      </a>
    </li>
  

    
      
      
      

  
  
  
    <li class="md-nav__item">
      <a href="../../../getting-started/" class="md-nav__link">
        Getting Started
      </a>
    </li>
  

    
      
      
      

  
  
  
    <li class="md-nav__item">
      <a href="../../../playground" class="md-nav__link">
        Playground
      </a>
    </li>
  

    
      
      
      

  
  
  
    <li class="md-nav__item">
      <a href="../../../download/" class="md-nav__link">
        Download
      </a>
    </li>
  

    
      
      
      

  
  
  
    
    <li class="md-nav__item md-nav__item--nested">
      
      
      
      
      <input class="md-nav__toggle md-toggle " type="checkbox" id="__nav_5" >
      
      
      
        <label class="md-nav__link" for="__nav_5" id="__nav_5_label" tabindex="0">
          Documentation
          <span class="md-nav__icon md-icon"></span>
        </label>
      
      <nav class="md-nav" data-md-level="1" aria-labelledby="__nav_5_label" aria-expanded="false">
        <label class="md-nav__title" for="__nav_5">
          <span class="md-nav__icon md-icon"></span>
          Documentation
        </label>
        <ul class="md-nav__list" data-md-scrollfix>
          
            
              
  
  
  
    <li class="md-nav__item">
      <a href="../../" class="md-nav__link">
        Overview
      </a>
    </li>
  

            
          
            
              
  
  
  
    <li class="md-nav__item">
      <a href="../../emc/" class="md-nav__link">
        Model Connectivity
      </a>
    </li>
  

            
          
            
              
  
  
  
    
    <li class="md-nav__item md-nav__item--nested">
      
      
      
      
      <input class="md-nav__toggle md-toggle " type="checkbox" id="__nav_5_3" >
      
      
      
        <label class="md-nav__link" for="__nav_5_3" id="__nav_5_3_label" tabindex="0">
          Languages
          <span class="md-nav__icon md-icon"></span>
        </label>
      
      <nav class="md-nav" data-md-level="2" aria-labelledby="__nav_5_3_label" aria-expanded="false">
        <label class="md-nav__title" for="__nav_5_3">
          <span class="md-nav__icon md-icon"></span>
          Languages
        </label>
        <ul class="md-nav__list" data-md-scrollfix>
          
            
              
  
  
  
    <li class="md-nav__item">
      <a href="../../eol/" class="md-nav__link">
        Object Language (EOL)
      </a>
    </li>
  

            
          
            
              
  
  
  
    <li class="md-nav__item">
      <a href="../../egl/" class="md-nav__link">
        Code Generation (EGL)
      </a>
    </li>
  

            
          
            
              
  
  
  
    <li class="md-nav__item">
      <a href="../../egx/" class="md-nav__link">
        Code Generation (EGX)
      </a>
    </li>
  

            
          
            
              
  
  
  
    <li class="md-nav__item">
      <a href="../../evl/" class="md-nav__link">
        Model Validation (EVL)
      </a>
    </li>
  

            
          
            
              
  
  
  
    <li class="md-nav__item">
      <a href="../../etl/" class="md-nav__link">
        Model Transformation (ETL)
      </a>
    </li>
  

            
          
            
              
  
  
  
    <li class="md-nav__item">
      <a href="../../ecl/" class="md-nav__link">
        Model Comparison (ECL)
      </a>
    </li>
  

            
          
            
              
  
  
  
    <li class="md-nav__item">
      <a href="../../eml/" class="md-nav__link">
        Model Merging (EML)
      </a>
    </li>
  

            
          
            
              
  
  
  
    <li class="md-nav__item">
      <a href="../../epl/" class="md-nav__link">
        Pattern Matching (EPL)
      </a>
    </li>
  

            
          
            
              
  
  
  
    <li class="md-nav__item">
      <a href="../../flock/" class="md-nav__link">
        Model Migration (Flock)
      </a>
    </li>
  

            
          
            
              
  
  
  
    <li class="md-nav__item">
      <a href="../../emg/" class="md-nav__link">
        Model Generation (EMG)
      </a>
    </li>
  

            
          
            
              
  
  
  
    <li class="md-nav__item">
      <a href="../../eunit/" class="md-nav__link">
        Unit Testing (EUnit)
      </a>
    </li>
  

            
          
            
              
  
  
  
    <li class="md-nav__item">
      <a href="../../pinset/" class="md-nav__link">
        Dataset Extraction (Pinset)
      </a>
    </li>
  

            
          
            
              
  
  
  
    <li class="md-nav__item">
      <a href="../../ewl/" class="md-nav__link">
        Wizard Language (EWL)
      </a>
    </li>
  

            
          
        </ul>
      </nav>
    </li>
  

            
          
            
              
  
  
  
    
    <li class="md-nav__item md-nav__item--nested">
      
      
      
      
      <input class="md-nav__toggle md-toggle " type="checkbox" id="__nav_5_4" >
      
      
      
        <label class="md-nav__link" for="__nav_5_4" id="__nav_5_4_label" tabindex="0">
          Tools
          <span class="md-nav__icon md-icon"></span>
        </label>
      
      <nav class="md-nav" data-md-level="2" aria-labelledby="__nav_5_4_label" aria-expanded="false">
        <label class="md-nav__title" for="__nav_5_4">
          <span class="md-nav__icon md-icon"></span>
          Tools
        </label>
        <ul class="md-nav__list" data-md-scrollfix>
          
            
              
  
  
  
    <li class="md-nav__item">
      <a href="../../picto/" class="md-nav__link">
        Picto
      </a>
    </li>
  

            
          
            
              
  
  
  
    <li class="md-nav__item">
      <a href="../../flexmi/" class="md-nav__link">
        Flexmi
      </a>
    </li>
  

            
          
            
              
  
  
  
    <li class="md-nav__item">
      <a href="../../eugenia/" class="md-nav__link">
        Eugenia
      </a>
    </li>
  

            
          
            
              
  
  
  
    <li class="md-nav__item">
      <a href="../../exeed/" class="md-nav__link">
        Exeed
      </a>
    </li>
  

            
          
            
              
  
  
  
    <li class="md-nav__item">
      <a href="../../modelink/" class="md-nav__link">
        Modelink
      </a>
    </li>
  

            
          
            
              
  
  
  
    <li class="md-nav__item">
      <a href="../../hutn/" class="md-nav__link">
        HUTN
      </a>
    </li>
  

            
          
            
              
  
  
  
    <li class="md-nav__item">
      <a href="../../workflow/" class="md-nav__link">
        Workflow (Ant tasks)
      </a>
    </li>
  

            
          
        </ul>
      </nav>
    </li>
  

            
          
            
              
  
  
  
    <li class="md-nav__item">
      <a href="../" class="md-nav__link">
        Articles
      </a>
    </li>
  

            
          
            
              
  
  
  
    <li class="md-nav__item">
      <a href="../../../examples/" class="md-nav__link">
        Examples
      </a>
    </li>
  

            
          
            
              
  
  
  
    <li class="md-nav__item">
      <a href="https://www.youtube.com/epsilondevs" class="md-nav__link">
        Screencasts
      </a>
    </li>
  

            
          
            
              
  
  
  
    <li class="md-nav__item">
      <a href="https://www.youtube.com/playlist?list=PLRwHao6Ue0YUecg7vEUQTrtySIWwrd_mI" class="md-nav__link">
        Lectures
      </a>
    </li>
  

            
          
            
              
  
  
  
    
    <li class="md-nav__item md-nav__item--nested">
      
      
      
      
      <input class="md-nav__toggle md-toggle " type="checkbox" id="__nav_5_9" >
      
      
      
        <label class="md-nav__link" for="__nav_5_9" id="__nav_5_9_label" tabindex="0">
          Javadoc
          <span class="md-nav__icon md-icon"></span>
        </label>
      
      <nav class="md-nav" data-md-level="2" aria-labelledby="__nav_5_9_label" aria-expanded="false">
        <label class="md-nav__title" for="__nav_5_9">
          <span class="md-nav__icon md-icon"></span>
          Javadoc
        </label>
        <ul class="md-nav__list" data-md-scrollfix>
          
            
              
  
  
  
    <li class="md-nav__item">
      <a href="https://download.eclipse.org/epsilon/stable-javadoc/" class="md-nav__link">
        Stable
      </a>
    </li>
  

            
          
            
              
  
  
  
    <li class="md-nav__item">
      <a href="https://download.eclipse.org/epsilon/interim-javadoc/" class="md-nav__link">
        Interim
      </a>
    </li>
  

            
          
        </ul>
      </nav>
    </li>
  

            
          
        </ul>
      </nav>
    </li>
  

    
      
      
      

  
  
  
    
    <li class="md-nav__item md-nav__item--nested">
      
      
      
      
      <input class="md-nav__toggle md-toggle " type="checkbox" id="__nav_6" >
      
      
      
        <label class="md-nav__link" for="__nav_6" id="__nav_6_label" tabindex="0">
          Issues
          <span class="md-nav__icon md-icon"></span>
        </label>
      
      <nav class="md-nav" data-md-level="1" aria-labelledby="__nav_6_label" aria-expanded="false">
        <label class="md-nav__title" for="__nav_6">
          <span class="md-nav__icon md-icon"></span>
          Issues
        </label>
        <ul class="md-nav__list" data-md-scrollfix>
          
            
              
  
  
  
    <li class="md-nav__item">
      <a href="https://github.com/eclipse/epsilon/issues/new/choose" class="md-nav__link">
        Report a new issue
      </a>
    </li>
  

            
          
            
              
  
  
  
    <li class="md-nav__item">
      <a href="https://github.com/eclipse/epsilon/issues" class="md-nav__link">
        View open issues
      </a>
    </li>
  

            
          
            
              
  
  
  
    <li class="md-nav__item">
      <a href="https://bugs.eclipse.org/bugs/buglist.cgi?product=epsilon&cmdtype=doit&order=Reuse+same+sort+as+last+time" class="md-nav__link">
        Bugzilla (legacy)
      </a>
    </li>
  

            
          
        </ul>
      </nav>
    </li>
  

    
      
      
      

  
  
  
    
    <li class="md-nav__item md-nav__item--nested">
      
      
      
      
      <input class="md-nav__toggle md-toggle " type="checkbox" id="__nav_7" >
      
      
      
        <label class="md-nav__link" for="__nav_7" id="__nav_7_label" tabindex="0">
          Community
          <span class="md-nav__icon md-icon"></span>
        </label>
      
      <nav class="md-nav" data-md-level="1" aria-labelledby="__nav_7_label" aria-expanded="false">
        <label class="md-nav__title" for="__nav_7">
          <span class="md-nav__icon md-icon"></span>
          Community
        </label>
        <ul class="md-nav__list" data-md-scrollfix>
          
            
              
  
  
  
    
    <li class="md-nav__item md-nav__item--nested">
      
      
      
      
      <input class="md-nav__toggle md-toggle " type="checkbox" id="__nav_7_1" >
      
      
      
        <label class="md-nav__link" for="__nav_7_1" id="__nav_7_1_label" tabindex="0">
          Who is using Epsilon?
          <span class="md-nav__icon md-icon"></span>
        </label>
      
      <nav class="md-nav" data-md-level="2" aria-labelledby="__nav_7_1_label" aria-expanded="false">
        <label class="md-nav__title" for="__nav_7_1">
          <span class="md-nav__icon md-icon"></span>
          Who is using Epsilon?
        </label>
        <ul class="md-nav__list" data-md-scrollfix>
          
            
              
  
  
  
    <li class="md-nav__item">
      <a href="../../../users/" class="md-nav__link">
        Industry
      </a>
    </li>
  

            
          
            
              
  
  
  
    <li class="md-nav__item">
      <a href="../../../users/education/" class="md-nav__link">
        Education
      </a>
    </li>
  

            
          
            
              
  
  
  
    <li class="md-nav__item">
      <a href="../../../users/open-source/" class="md-nav__link">
        Open-source Projects
      </a>
    </li>
  

            
          
        </ul>
      </nav>
    </li>
  

            
          
            
              
  
  
  
    <li class="md-nav__item">
      <a href="https://projects.eclipse.org/projects/modeling.epsilon/who" class="md-nav__link">
        Who is developing Epsilon?
      </a>
    </li>
  

            
          
            
              
  
  
  
    <li class="md-nav__item">
      <a href="https://ko-fi.com/eclipseepsilon" class="md-nav__link">
        How can I support Epsilon?
      </a>
    </li>
  

            
          
            
              
  
  
  
    <li class="md-nav__item">
      <a href="https://www.eclipse.org/forums/index.php/f/22/" class="md-nav__link">
        Forum
      </a>
    </li>
  

            
          
            
              
  
  
  
    <li class="md-nav__item">
      <a href="../../../professional-services" class="md-nav__link">
        Professional Services
      </a>
    </li>
  

            
          
            
              
  
  
  
    
    <li class="md-nav__item md-nav__item--nested">
      
      
      
      
      <input class="md-nav__toggle md-toggle " type="checkbox" id="__nav_7_6" >
      
      
      
        <label class="md-nav__link" for="__nav_7_6" id="__nav_7_6_label" tabindex="0">
          Social Media
          <span class="md-nav__icon md-icon"></span>
        </label>
      
      <nav class="md-nav" data-md-level="2" aria-labelledby="__nav_7_6_label" aria-expanded="false">
        <label class="md-nav__title" for="__nav_7_6">
          <span class="md-nav__icon md-icon"></span>
          Social Media
        </label>
        <ul class="md-nav__list" data-md-scrollfix>
          
            
              
  
  
  
    <li class="md-nav__item">
      <a href="https://twitter.com/eclipseepsilon" class="md-nav__link">
        Twitter
      </a>
    </li>
  

            
          
            
              
  
  
  
    <li class="md-nav__item">
      <a href="https://youtube.com/epsilondevs" class="md-nav__link">
        YouTube
      </a>
    </li>
  

            
          
        </ul>
      </nav>
    </li>
  

            
          
            
              
  
  
  
    <li class="md-nav__item">
      <a href="../../../labs/" class="md-nav__link">
        Epsilon Labs
      </a>
    </li>
  

            
          
            
              
  
  
  
    <li class="md-nav__item">
      <a href="../../../faq/" class="md-nav__link">
        Frequently Asked Questions
      </a>
    </li>
  

            
          
        </ul>
      </nav>
    </li>
  

    
      
      
      

  
  
  
    <li class="md-nav__item">
      <a href="../../../branding/" class="md-nav__link">
        Branding
      </a>
    </li>
  

    
  </ul>
</nav>
                  </div>
                </div>
              </div>
            
            
              
              <div class="md-sidebar md-sidebar--secondary" data-md-component="sidebar" data-md-type="toc" >
                <div class="md-sidebar__scrollwrap">
                  <div class="md-sidebar__inner">
                    

<nav class="md-nav md-nav--secondary" aria-label="Table of contents">
  
  
  
    
  
  
    <label class="md-nav__title" for="__toc">
      <span class="md-nav__icon md-icon"></span>
      Table of contents
    </label>
    <ul class="md-nav__list" data-md-component="toc" data-md-scrollfix>
      
        <li class="md-nav__item">
  <a href="#but-wait-a-second-why-should-i-want-to-do-this" class="md-nav__link">
    But, wait a second, why should I want to do this?
  </a>
  
</li>
      
        <li class="md-nav__item">
  <a href="#how-does-it-differ-from-other-tools" class="md-nav__link">
    How does it differ from other tools?
  </a>
  
</li>
      
        <li class="md-nav__item">
  <a href="#how-is-it-used" class="md-nav__link">
    How is it used?
  </a>
  
</li>
      
        <li class="md-nav__item">
  <a href="#what-other-things-can-i-do" class="md-nav__link">
    What other things can I do?
  </a>
  
</li>
      
        <li class="md-nav__item">
  <a href="#applications" class="md-nav__link">
    Applications
  </a>
  
</li>
      
    </ul>
  
</nav>
                  </div>
                </div>
              </div>
            
          
          
            <div class="md-content" data-md-component="content">
              <article class="md-content__inner md-typeset">
                
                  

  
  


<h1 id="treating-java-code-as-a-model-in-epsilon">Treating Java code as a model in Epsilon<a class="headerlink" href="#treating-java-code-as-a-model-in-epsilon" title="Permanent link">&para;</a></h1>
<p>In version 2.4 of Epsilon we introduced <strong>a driver that allows Epsilon languages to query Java code as if it were a model</strong>, using the internal representations of the Eclipse <a href="https://www.eclipse.org/jdt/">Java Development Tools</a>.</p>
<h2 id="but-wait-a-second-why-should-i-want-to-do-this">But, wait a second, why should I want to do this?<a class="headerlink" href="#but-wait-a-second-why-should-i-want-to-do-this" title="Permanent link">&para;</a></h2>
<p>There are many cases in which you may want to check things about your code. In many cases, a simple text-based search or the code navigation facilities in your IDE might be enough.  For instance, finding a class by name or listing its inherited methods  is something we do all the time.</p>
<p>However, <strong>what if you want to check something very particular which is not supported by your IDE, and which involves “understanding” Java?</strong> As an example, suppose that you want to find all the places in your  code where a new programmer may have used <code>==</code> to compare floating-point  numbers. This is a very <a href="http://floating-point-gui.de/errors/comparison/">common mistake</a> that novices make.</p>
<p><strong>Text search won’t help you</strong>: floating-point expressions and variables can be arbitrarily complex. You will need to parse the Java code, find these <code>==</code> comparisons and reimplement the bits of the Java Language Specification needed to find if one of the two sides is a floating-point expression. Too much work for a quick check you wanted to run on your code!</p>
<p>A simpler approach would be to have a tool give you a representation of the code that is close to how the  compiler thinks about it, and that you can go through easily. This is what we mean with having a <em>model</em>. In particular, this example would be solved with our tool by writing this snippet of EOL code:</p>
<div class="highlight"><pre><span></span><code><span class="k">for</span><span class="w"> </span><span class="p">(</span><span class="n">expr</span><span class="w"> </span><span class="n">in</span><span class="w"> </span><span class="n">InfixExpression</span><span class="p">.</span><span class="na">all</span><span class="p">)</span><span class="w"> </span><span class="p">{</span>
<span class="w">  </span><span class="k">if</span><span class="w"> </span><span class="p">(</span><span class="n">expr</span><span class="p">.</span><span class="na">operator</span><span class="p">.</span><span class="na">toString</span><span class="p">()</span><span class="w"> </span><span class="o">==</span><span class="w"> </span><span class="s">&quot;==&quot;</span><span class="p">)</span><span class="w"> </span><span class="p">{</span>
<span class="w">    </span><span class="kd">var</span><span class="w"> </span><span class="n">typeLExpr</span><span class="w"> </span><span class="o">=</span><span class="w"> </span>
<span class="w">      </span><span class="n">expr</span><span class="p">.</span><span class="na">leftOperand</span><span class="p">.</span><span class="na">resolveTypeBinding</span><span class="p">().</span><span class="na">qualifiedName</span><span class="p">;</span>
<span class="w">    </span><span class="kd">var</span><span class="w"> </span><span class="n">typeRExpr</span><span class="w"> </span><span class="o">=</span>
<span class="w">      </span><span class="n">expr</span><span class="p">.</span><span class="na">rightOperand</span><span class="p">.</span><span class="na">resolveTypeBinding</span><span class="p">().</span><span class="na">qualifiedName</span><span class="p">;</span>
<span class="w">    </span><span class="k">if</span><span class="w"> </span><span class="p">(</span><span class="n">typeLExpr</span><span class="w"> </span><span class="o">==</span><span class="w"> </span><span class="s">&quot;float&quot;</span><span class="w"> </span><span class="n">or</span><span class="w"> </span><span class="n">typeRExpr</span><span class="w"> </span><span class="o">==</span><span class="w"> </span><span class="s">&quot;float&quot;</span><span class="p">)</span><span class="w"> </span><span class="p">{</span>
<span class="w">      </span><span class="kd">var</span><span class="w"> </span><span class="n">cUnit</span><span class="w"> </span><span class="o">=</span><span class="w"> </span><span class="n">expr</span><span class="p">.</span><span class="na">root</span><span class="p">.</span><span class="na">javaElement</span><span class="p">.</span><span class="na">elementName</span><span class="p">;</span>
<span class="w">      </span><span class="p">(</span><span class="s">&quot;WARNING: in &quot;</span><span class="w"> </span><span class="o">+</span><span class="w"> </span><span class="n">cUnit</span>
<span class="w">       </span><span class="o">+</span><span class="w"> </span><span class="s">&quot;, tried to use == with a float: &quot;</span>
<span class="w">       </span><span class="o">+</span><span class="w"> </span><span class="n">expr</span><span class="p">).</span><span class="na">println</span><span class="p">();</span>
<span class="w">    </span><span class="p">}</span>
<span class="w">  </span><span class="p">}</span>
<span class="p">}</span>
</code></pre></div>
<p>This query finds the <code>==</code> expressions  in your code, reuses the Eclipse Java Developer Tools to find if one of  the two sides is a <code>float</code> (we’re ignoring <code>double</code> to simplify things), and then reports any problems. It can handle non-trivial cases like method invocations, array accesses and so on. And all in 12 lines of  code.</p>
<h2 id="how-does-it-differ-from-other-tools">How does it differ from other tools?<a class="headerlink" href="#how-does-it-differ-from-other-tools" title="Permanent link">&para;</a></h2>
<p>The usual approach when exposing code as a model is to parse the code, dump it as a model (e.g in XMI) and  then treat it as usual. This approach is followed by popular tools such as <a href="https://eclipse.org/MoDisco/">MoDisco</a>, and it works well in “software modernization” situations in which you have a “frozen” legacy code base. This is the bottom path shown on this figure, starting from “Java code” and going to the cyan nodes:</p>
<p><img alt="img" src="alternatives.png" /></p>
<p>However, <strong>if you have an active codebase, having to extract a full model every time you make a change is tedious and slows you down</strong>. Instead, it’d be better to just have something running in the  background keeping such a model up to date. The good news is that many IDEs already do this for their code navigation facilities, so we can piggyback on it without adding yet another background process to the  user experience.</p>
<p>Our EMC JDT driver is exactly that – we don’t do any big extraction work in advance, so the query starts  running almost immediately. The driver exposes the indices maintained by the Eclipse Java Development Tools, so you can quickly find a class and go through its methods, for instance. If at some point you need more  information than the indices provide, we’ll transparently use the JDT  parser (based on the Java compiler) to fetch things for you. This is  represented as the top path in the above figure, starting at “Java code” and going through the orange nodes.</p>
<h2 id="how-is-it-used">How is it used?<a class="headerlink" href="#how-is-it-used" title="Permanent link">&para;</a></h2>
<p>With Epsilon and the EMC JDT driver  installed, we create a new “query.eol” file with our query. For  instance, this one-liner prints how many types we have in our program:</p>
<pre class="prettyprint lang-eol"><code>TypeDeclaration.all.size.println("number of types: ");</code></pre>
<p>To run it, we create a standard EOL launch configuration and then select the new “Java” model type: </p>
<p><img alt="img" src="select-model.png" /></p>
<p>We then select a set of Eclipse Java projects to expose as a model: </p>
<p><img alt="img" src="jdt-config.png" /></p>
<p>You can select multiple projects  through Ctrl+click – these will all be exposed as a single model. Here I have code for various versions of the <a href="http://www.jfree.org/jfreechart/">JFreeChart library</a>, and I have selected the code for the 1.0.19 version in particular.</p>
<p>Click on <code>OK</code>, then <code>Run</code>, and you’ll get your answer:</p>
<div class="highlight"><pre><span></span><code>number of types: 1041
</code></pre></div>
<h2 id="what-other-things-can-i-do">What other things can I do?<a class="headerlink" href="#what-other-things-can-i-do" title="Permanent link">&para;</a></h2>
<p>While the previous example was very  simple, EOL is a fully-featured language, with support for loops,  user-defined operations, built-in data structures and full access to any Java library. In <a href="https://oclworkshop.github.io/2016/papers/OCL16_paper_4.pdf">this paper</a> we showed <strong>how to use it to validate your real Java code against a UML diagram, checking if perhaps your UML diagram had gone “stale”</strong>. We found that using the EMC JDT driver would be faster than using  MoDisco if you just wanted to do this check repeatedly across multiple  releases.</p>
<p>Essentially, we expose the <a href="https://help.eclipse.org/latest/index.jsp?topic=%2Forg.eclipse.jdt.doc.isv%2Freference%2Fapi%2Forg%2Feclipse%2Fjdt%2Fcore%2Fdom%2Fpackage-summary.html">JDT document object model (DOM)</a> directly through Epsilon, so if you want to access all instances of the JDT DOM <a href="https://help.eclipse.org/latest/index.jsp?topic=%2Forg.eclipse.jdt.doc.isv%2Freference%2Fapi%2Forg%2Feclipse%2Fjdt%2Fcore%2Fdom%2FAST.html">TypeDeclaration class</a>, you write <code>TypeDeclaration.all</code> as we did above. We also provide a few  convenient shorthands. For a TypeDeclaration t, you can use these:</p>
<ul>
<li><code>t.public</code>,  <code>t.protected</code>, <code>t.private</code>, <code>t.static</code>, <code>t.abstract</code>, <code>t.final</code>: these are  true/false depending on whether the underlying type has this modifier.</li>
<li><code>t.name</code>: this exposes the name of the underlying type (which usually requires going through multiple fields).</li>
</ul>
<p>We also expose the JDT index so you  can quickly find a type by name: in fact, it’s the same index you use  when pressing <code>CTRL+SHIFT+T</code> on Eclipse. To do so, you can use one of  these:</p>
<ul>
<li><code>TypeDeclaration.all.select(td|td.name="someClass")</code> finds a type by name and returns it as a collection of TypeDeclarations with access to every detail within those types.</li>
<li><code>TypeDeclaration.all.search(td|td.name="someClass")</code> does the same, but it only returns the raw index entry (an instance of <a href="https://help.eclipse.org/latest/index.jsp?topic=%2Forg.eclipse.jdt.doc.isv%2Freference%2Fapi%2Forg%2Feclipse%2Fjdt%2Fcore%2FIType.html">IType</a>), which is much faster but has less information.</li>
</ul>
<h2 id="applications">Applications<a class="headerlink" href="#applications" title="Permanent link">&para;</a></h2>
<p>In <a href="https://github.com/eclipse/epsilon/tree/main/examples/org.eclipse.epsilon.examples.jdt.picto">this example</a>, we use the JDT driver and <a href="../../picto">Picto</a> to generate PlantUML diagrams from existing Java code on the fly.</p>
<p><img alt="" src="picto-jdt.png" /></p>
<div class="tabbed-set tabbed-alternate" data-tabs="1:4"><input checked="checked" id="__tabbed_1_1" name="__tabbed_1" type="radio" /><input id="__tabbed_1_2" name="__tabbed_1" type="radio" /><input id="__tabbed_1_3" name="__tabbed_1" type="radio" /><input id="__tabbed_1_4" name="__tabbed_1" type="radio" /><div class="tabbed-labels"><label for="__tabbed_1_1">jcd.flexmi</label><label for="__tabbed_1_2">jcd.picto</label><label for="__tabbed_1_3">jcd.egx</label><label for="__tabbed_1_4">cd.egl</label></div>
<div class="tabbed-content">
<div class="tabbed-block">
<div class="highlight"><pre><span></span><code><span class="cp">&lt;?nsuri jcd?&gt;</span>
<span class="nt">&lt;_&gt;</span>
<span class="w">    </span><span class="nt">&lt;diagram</span><span class="w"> </span><span class="na">name=</span><span class="s">&quot;Kitchen Sink&quot;</span><span class="nt">&gt;</span>
<span class="w">        </span><span class="nt">&lt;include</span><span class="w"> </span><span class="na">name=</span><span class="s">&quot;Employee&quot;</span><span class="nt">/&gt;</span>
<span class="w">        </span><span class="nt">&lt;include</span><span class="w"> </span><span class="na">name=</span><span class="s">&quot;Product&quot;</span><span class="nt">/&gt;</span>
<span class="w">        </span><span class="nt">&lt;include</span><span class="w"> </span><span class="na">name=</span><span class="s">&quot;Order&quot;</span><span class="nt">/&gt;</span>
<span class="w">        </span><span class="nt">&lt;include</span><span class="w"> </span><span class="na">name=</span><span class="s">&quot;OrderItem&quot;</span><span class="nt">/&gt;</span>
<span class="w">        </span><span class="nt">&lt;include</span><span class="w"> </span><span class="na">name=</span><span class="s">&quot;Person&quot;</span><span class="nt">/&gt;</span>
<span class="w">        </span><span class="nt">&lt;include</span><span class="w"> </span><span class="na">name=</span><span class="s">&quot;Shippable&quot;</span><span class="nt">/&gt;</span>
<span class="w">        </span><span class="nt">&lt;include</span><span class="w"> </span><span class="na">name=</span><span class="s">&quot;Address&quot;</span><span class="nt">/&gt;</span>
<span class="w">        </span><span class="nt">&lt;include</span><span class="w"> </span><span class="na">name=</span><span class="s">&quot;Customer&quot;</span><span class="nt">/&gt;</span>
<span class="w">        </span><span class="nt">&lt;constraint</span><span class="w"> </span><span class="na">below=</span><span class="s">&quot;Order&quot;</span><span class="w"> </span><span class="na">above=</span><span class="s">&quot;Employee&quot;</span><span class="nt">/&gt;</span>
<span class="w">        </span><span class="nt">&lt;constraint</span><span class="w"> </span><span class="na">below=</span><span class="s">&quot;OrderItem&quot;</span><span class="w"> </span><span class="na">above=</span><span class="s">&quot;Product&quot;</span><span class="nt">/&gt;</span>
<span class="w">        </span><span class="nt">&lt;constraint</span><span class="w"> </span><span class="na">above=</span><span class="s">&quot;Customer&quot;</span><span class="w"> </span><span class="na">below=</span><span class="s">&quot;Order&quot;</span><span class="nt">/&gt;</span>
<span class="w">        </span><span class="nt">&lt;constraint</span><span class="w"> </span><span class="na">right=</span><span class="s">&quot;Customer&quot;</span><span class="w"> </span><span class="na">left=</span><span class="s">&quot;Address&quot;</span><span class="nt">/&gt;</span>
<span class="w">    </span><span class="nt">&lt;/diagram&gt;</span>

<span class="w">    </span><span class="nt">&lt;diagram</span><span class="w"> </span><span class="na">name=</span><span class="s">&quot;Employee and Person&quot;</span><span class="nt">&gt;</span>
<span class="w">        </span><span class="nt">&lt;preamble&gt;</span>
<span class="w">        </span>skinparam<span class="w"> </span>monochrome<span class="w"> </span>true
<span class="w">        </span>skinparam<span class="w"> </span>handwritten<span class="w"> </span>true
<span class="w">        </span><span class="nt">&lt;/preamble&gt;</span>
<span class="w">        </span><span class="nt">&lt;postamble&gt;</span>
<span class="w">        </span>note<span class="w"> </span>left<span class="w"> </span>of<span class="w"> </span>Employee:<span class="w"> </span>People<span class="w"> </span>working<span class="w"> </span>for<span class="w"> </span>our<span class="w"> </span>company
<span class="w">        </span>note<span class="w"> </span>right<span class="w"> </span>of<span class="w"> </span>Person::&quot;lastName<span class="w"> </span>:<span class="w"> </span>String&quot;
<span class="w">        </span>The<span class="w"> </span>person&#39;s<span class="w"> </span>last<span class="w"> </span>name
<span class="w">        </span>end<span class="w"> </span>note
<span class="w">        </span><span class="nt">&lt;/postamble&gt;</span>
<span class="w">        </span><span class="nt">&lt;include</span><span class="w"> </span><span class="na">name=</span><span class="s">&quot;Employee&quot;</span><span class="nt">/&gt;</span>
<span class="w">        </span><span class="nt">&lt;include</span><span class="w"> </span><span class="na">name=</span><span class="s">&quot;Person&quot;</span><span class="nt">/&gt;</span>
<span class="w">    </span><span class="nt">&lt;/diagram&gt;</span>

<span class="w">    </span><span class="nt">&lt;diagram</span><span class="w"> </span><span class="na">name=</span><span class="s">&quot;Employee but not Person&quot;</span><span class="nt">&gt;</span>
<span class="w">        </span><span class="nt">&lt;include</span><span class="w"> </span><span class="na">name=</span><span class="s">&quot;Employee&quot;</span><span class="nt">/&gt;</span>
<span class="w">    </span><span class="nt">&lt;/diagram&gt;</span>

<span class="w">    </span><span class="nt">&lt;diagram</span><span class="w"> </span><span class="na">name=</span><span class="s">&quot;Order and Shippable&quot;</span><span class="nt">&gt;</span>
<span class="w">        </span><span class="nt">&lt;include</span><span class="w"> </span><span class="na">name=</span><span class="s">&quot;Order&quot;</span><span class="nt">/&gt;</span>
<span class="w">        </span><span class="nt">&lt;include</span><span class="w"> </span><span class="na">name=</span><span class="s">&quot;Shippable&quot;</span><span class="nt">/&gt;</span>
<span class="w">        </span><span class="nt">&lt;constraint</span><span class="w"> </span><span class="na">right=</span><span class="s">&quot;Order&quot;</span><span class="w"> </span><span class="na">left=</span><span class="s">&quot;Shippable&quot;</span><span class="nt">/&gt;</span>
<span class="w">    </span><span class="nt">&lt;/diagram&gt;</span>

<span class="w">    </span><span class="nt">&lt;diagram</span><span class="w"> </span><span class="na">name=</span><span class="s">&quot;Order but not Shippable&quot;</span><span class="nt">&gt;</span>
<span class="w">        </span><span class="nt">&lt;include</span><span class="w"> </span><span class="na">name=</span><span class="s">&quot;Order&quot;</span><span class="nt">/&gt;</span>
<span class="w">    </span><span class="nt">&lt;/diagram&gt;</span>
<span class="nt">&lt;/_&gt;</span>
</code></pre></div>
</div>
<div class="tabbed-block">
<div class="highlight"><pre><span></span><code><span class="cp">&lt;?nsuri picto?&gt;</span>
<span class="nt">&lt;picto</span><span class="w"> </span><span class="na">format=</span><span class="s">&quot;egx&quot;</span><span class="w"> </span><span class="na">transformation=</span><span class="s">&quot;jcd.egx&quot;</span><span class="w"> </span><span class="na">standalone=</span><span class="s">&quot;true&quot;</span><span class="nt">&gt;</span>
<span class="w">     </span><span class="nt">&lt;model</span><span class="w"> </span><span class="na">type=</span><span class="s">&quot;EMF&quot;</span><span class="nt">&gt;</span>
<span class="w">        </span><span class="nt">&lt;parameter</span><span class="w"> </span><span class="na">name=</span><span class="s">&quot;name&quot;</span><span class="w"> </span><span class="na">value=</span><span class="s">&quot;JCD&quot;</span><span class="nt">/&gt;</span>
<span class="w">        </span><span class="nt">&lt;parameter</span><span class="w"> </span><span class="na">name=</span><span class="s">&quot;metamodelUri&quot;</span><span class="w"> </span><span class="na">value=</span><span class="s">&quot;jcd&quot;</span><span class="nt">/&gt;</span>
<span class="w">        </span><span class="nt">&lt;parameter</span><span class="w"> </span><span class="na">name=</span><span class="s">&quot;modelFile&quot;</span><span class="w"> </span><span class="na">file=</span><span class="s">&quot;jcd.flexmi&quot;</span><span class="nt">/&gt;</span>
<span class="w">    </span><span class="nt">&lt;/model&gt;</span>
<span class="w">     </span><span class="nt">&lt;model</span><span class="w"> </span><span class="na">type=</span><span class="s">&quot;JDT&quot;</span><span class="nt">&gt;</span>
<span class="w">        </span><span class="nt">&lt;parameter</span><span class="w"> </span><span class="na">name=</span><span class="s">&quot;name&quot;</span><span class="w"> </span><span class="na">value=</span><span class="s">&quot;JDT&quot;</span><span class="nt">/&gt;</span>
<span class="w">        </span><span class="nt">&lt;parameter</span><span class="w"> </span><span class="na">name=</span><span class="s">&quot;projects&quot;</span><span class="w"> </span><span class="na">value=</span><span class="s">&quot;org.eclipse.epsilon.examples.jdt.picto&quot;</span><span class="nt">/&gt;</span>
<span class="w">    </span><span class="nt">&lt;/model&gt;</span><span class="w">    </span>
<span class="nt">&lt;/picto&gt;</span>
</code></pre></div>
</div>
<div class="tabbed-block">
<pre class="prettyprint lang-egx"><code>rule Diagram2PlantUML 
    transform diagram : JCD!Diagram {

    template : "cd.egl"

    parameters : Map{
        "path" = Sequence{diagram.name},
        "format" = "puml"
    }

}</code></pre>
</div>
<div class="tabbed-block">
<pre class="prettyprint lang-egl"><code>@startuml
hide circle
[%diagram.populate();%]
[%=diagram.preamble%]
[%for (class in diagram.types.select(t|t.isTypeOf(Class))){%]
class [%=class.name%] {
    [%for (attribute in class.attributes){%]
    [%=attribute.name%] : [%=attribute.type%]
    [%}%]
    [%for (method in class.methods) { %]
    [%=method.getLabel()%]
    [%}%]
}

[%for (reference in class.references){%]
[%=reference.getEdge()%]
[%}%]

[%for (superType in class.superTypes){%]
[%=getEdge(class, superType)%]
[%}%]

[%}%]
[%=diagram.postamble%]
@enduml

[%
operation JCD!Diagram populate() {

    // Resolve type declaration from includes and create types
    for (include in self.includes) {
        var typeDeclaration = JDT!TypeDeclaration.all.select(td|td.name = include.name).first();
        if (typeDeclaration.isDefined()) {
            var class = new JCD!Class;
            class.name = typeDeclaration.name.identifier;
            self.types.add(class);
            class.~typeDeclaration = typeDeclaration;
        }
    }

    // Populate supertypes
    for (class in self.types.select(t|t.isTypeOf(JCD!Class) and t.~typeDeclaration.isDefined())) {
        if (class.~typeDeclaration.getSuperclassType().isDefined()) {
            class.superTypes.addAll(self.types.select(c:JCD!Class|c.name = class.~typeDeclaration.getSuperclassType().toString()/*name.identifier*/));
        }

        for (interface in class.~typeDeclaration.superInterfaceTypes()) {
            class.superTypes.addAll(self.types.select(c:JCD!Class|c.name = interface.name.identifier)); 
        }
    }

    // Populate class attributes, references and methods
    for (class in self.types.select(t|t.isTypeOf(JCD!Class) and t.~typeDeclaration.isDefined())) {
        for (field in class.~typeDeclaration.fields) {
            if (not field.getType().isVisible(diagram)) {
                var attribute = new JCD!Attribute;
                attribute.name = field.getName();
                attribute.type = field.getType().getLabel();
                attribute.many = field.isCollection();
                class.attributes.add(attribute);
            }
            else {
                var reference = new JCD!Reference;
                reference.name = field.getName();
                reference.type = diagram.types.selectOne(c|c.name = field.getType().name.identifier);
                reference.many = field.isCollection();
                class.references.add(reference);
            }
        }

        // Populate class methods
        for (methodDeclaration in class.~typeDeclaration.methods) {
            var method = new JCD!Method;
            method.name = methodDeclaration.name.identifier;
            for (formalParameter in methodDeclaration.parameters()) {
                var parameter : new JCD!Parameter;
                parameter.name = formalParameter.name.identifier;
                parameter.type = formalParameter.type.getLabel();
                method.parameters.add(parameter);
            }
            //method.type = methodDeclaration.returnType2.getLabel();
            class.methods.add(method);
        }

    }


}

/**
 * Produces a generalization edge, taking into account contstraints
 */ 
operation getEdge(class:JCD!Class, superClass:JCD!Class) {
    var diagram = class.eContainer();

    if (diagram.constraints.exists(c|c.above = class.name and c.below = superClass.name)) {
        return class.name + " --|&gt; " + superClass.name;
    }
    else if (diagram.constraints.exists(c|c.left = class.name and c.right = superClass.name)) {
        return class.name + " -|&gt; " + superClass.name;
    }
    else if (diagram.constraints.exists(c|c.left = superClass.name and c.right = class.name)) {
        return superClass.name + " &lt;|- " + class.name;
    }
    else {
        return superClass.name + " &lt;|-- " + class.name;
    }
}

/*
 * Prdoduces a reference edge, taking into account constraints
 */
operation JCD!Reference getEdge() {
    var diagram = self.eContainer().eContainer();
    var label = " \" " + self.name + (self.many ? "*" : "") + "\" ";

    if (diagram.constraints.exists(c|c.above = self.eContainer().name and c.below = self.type.name)) {
        return self.eContainer().name + " -down-&gt; " + self.type.name + " : " + label;
    }
    else if (diagram.constraints.exists(c|c.below = self.eContainer().name and c.above = self.type.name)) {
        return self.eContainer().name + " -up-&gt; " + self.type.name + " : " + label;
    }
    else if (diagram.constraints.exists(c|c.right = self.eContainer().name and c.left = self.type.name)) {
        return self.eContainer().name + " -left-&gt; " + self.type.name + " : " + label;
    }
    else {
        return self.eContainer().name + " -right-&gt; " + self.type.name + " : " + label;
    }
}

operation JDT!FieldDeclaration getName() {
    return self.fragments.at(0)/*VariableDeclarationFragment*/.name.identifier;
}

operation JDT!ParameterizedType getLabel() {
    return self.type.name + "&lt;" + self.typeArguments.collect(ta|ta.getLabel()).concat(", ") + "&gt;";
}

operation JDT!WildcardType getLabel() {
    return self.toString();
}

operation JDT!SimpleType getLabel() {
    return self.name.identifier;
}

operation JDT!PrimitiveType getLabel() {
    return self.toString();
}

operation JDT!FieldDeclaration getType() {
    if (self.isCollection()) {
        return self.type.typeArguments.first();
    }
    else {
        return self.type;
    }
}

operation JDT!FieldDeclaration isCollection() {
    return self.type.isTypeOf(JDT!ParameterizedType) 
        and self.type.typeArguments.size() == 1 
        and self.type.type.name.identifier = "List"; /*FIXME*/
}

operation JDT!Type isVisible(diagram : JCD!Diagram) {
    if (not self.isTypeOf(JDT!SimpleType)) return false;
    return diagram.types.name.includes(self.name.identifier);
}

operation JCD!Method getLabel() {
    var label = self.name + "(" + self.parameters.collect(p|p.name + ":" + p.type).concat(", ") + ")";
    if (self.type.isDefined() and self.type != "void") label += " : " + self.type;
    return label;
}

%]</code></pre>
</div>
</div>
</div>





                
              </article>
            </div>
          
          
  <script>var tabs=__md_get("__tabs");if(Array.isArray(tabs))e:for(var set of document.querySelectorAll(".tabbed-set")){var tab,labels=set.querySelector(".tabbed-labels");for(tab of tabs)for(var label of labels.getElementsByTagName("label"))if(label.innerText.trim()===tab){var input=document.getElementById(label.htmlFor);input.checked=!0;continue e}}</script>

        </div>
        
      </main>
      
        <footer class="md-footer">
  
    
  
  <div class="md-footer-meta md-typeset">
    <div class="md-footer-meta__inner md-grid">
      <div class="md-copyright">
  
    <div class="md-copyright__highlight">
      Copyright © <a href="https://www.eclipse.org">Eclipse Foundation, Inc.</a> All Rights Reserved <br/> <a href="https://www.eclipse.org/legal/privacy.php">Privacy Policy</a> &centerdot; <a href="https://www.eclipse.org/legal/termsofuse.php">Terms of Use</a> &centerdot; <a href="https://www.eclipse.org/legal/copyright.php">Copyright Agent</a>  &centerdot; <a href="https://www.eclipse.org/legal/">Legal</a><p><img src="https://eclipse.dev/epsilon/assets/images/eclipse-foundation-logo.svg"/></p>
    </div>
  
  
    Made with
    <a href="https://squidfunk.github.io/mkdocs-material/" target="_blank" rel="noopener">
      Material for MkDocs
    </a>
  
</div>
      
        <div class="md-social">
  
    
    
    
    
      
      
    
    <a href="https://twitter.com/eclipseepsilon" target="_blank" rel="noopener" title="twitter.com" class="md-social__link">
      <svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 512 512"><!--! Font Awesome Free 6.4.0 by @fontawesome - https://fontawesome.com License - https://fontawesome.com/license/free (Icons: CC BY 4.0, Fonts: SIL OFL 1.1, Code: MIT License) Copyright 2023 Fonticons, Inc.--><path d="M459.37 151.716c.325 4.548.325 9.097.325 13.645 0 138.72-105.583 298.558-298.558 298.558-59.452 0-114.68-17.219-161.137-47.106 8.447.974 16.568 1.299 25.34 1.299 49.055 0 94.213-16.568 130.274-44.832-46.132-.975-84.792-31.188-98.112-72.772 6.498.974 12.995 1.624 19.818 1.624 9.421 0 18.843-1.3 27.614-3.573-48.081-9.747-84.143-51.98-84.143-102.985v-1.299c13.969 7.797 30.214 12.67 47.431 13.319-28.264-18.843-46.781-51.005-46.781-87.391 0-19.492 5.197-37.36 14.294-52.954 51.655 63.675 129.3 105.258 216.365 109.807-1.624-7.797-2.599-15.918-2.599-24.04 0-57.828 46.782-104.934 104.934-104.934 30.213 0 57.502 12.67 76.67 33.137 23.715-4.548 46.456-13.32 66.599-25.34-7.798 24.366-24.366 44.833-46.132 57.827 21.117-2.273 41.584-8.122 60.426-16.243-14.292 20.791-32.161 39.308-52.628 54.253z"/></svg>
    </a>
  
    
    
    
    
      
      
    
    <a href="https://youtube.com/epsilondevs" target="_blank" rel="noopener" title="youtube.com" class="md-social__link">
      <svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 576 512"><!--! Font Awesome Free 6.4.0 by @fontawesome - https://fontawesome.com License - https://fontawesome.com/license/free (Icons: CC BY 4.0, Fonts: SIL OFL 1.1, Code: MIT License) Copyright 2023 Fonticons, Inc.--><path d="M549.655 124.083c-6.281-23.65-24.787-42.276-48.284-48.597C458.781 64 288 64 288 64S117.22 64 74.629 75.486c-23.497 6.322-42.003 24.947-48.284 48.597-11.412 42.867-11.412 132.305-11.412 132.305s0 89.438 11.412 132.305c6.281 23.65 24.787 41.5 48.284 47.821C117.22 448 288 448 288 448s170.78 0 213.371-11.486c23.497-6.321 42.003-24.171 48.284-47.821 11.412-42.867 11.412-132.305 11.412-132.305s0-89.438-11.412-132.305zm-317.51 213.508V175.185l142.739 81.205-142.739 81.201z"/></svg>
    </a>
  
</div>
      
    </div>
  </div>
</footer>
      
    </div>
    <div class="md-dialog" data-md-component="dialog">
      <div class="md-dialog__inner md-typeset"></div>
    </div>
    
    <script id="__config" type="application/json">{"base": "../../..", "features": ["content.code.copy", "content.tabs.link", "navigation.footer"], "search": "../../../assets/javascripts/workers/search.74e28a9f.min.js", "translations": {"clipboard.copied": "Copied to clipboard", "clipboard.copy": "Copy to clipboard", "search.result.more.one": "1 more on this page", "search.result.more.other": "# more on this page", "search.result.none": "No matching documents", "search.result.one": "1 matching document", "search.result.other": "# matching documents", "search.result.placeholder": "Type to start searching", "search.result.term.missing": "Missing", "select.version": "Select version"}}</script>
    
    
      <script src="../../../assets/javascripts/bundle.220ee61c.min.js"></script>
      
        
          <script src="https://unpkg.com/mermaid@8.5.1/dist/mermaid.min.js"></script>
        
      
        
          <script src="../../../assets/javascript/mermaid.js"></script>
        
      
        
          <script src="../../../assets/javascript/jquery.js"></script>
        
      
        
          <script src="../../../assets/javascript/slick.min.js"></script>
        
      
        
          <script src="../../../assets/javascript/google-code-prettify/prettify.js"></script>
        
      
        
          <script src="../../../assets/javascript/google-code-prettify/lang-emfatic.js"></script>
        
      
        
          <script src="../../../assets/javascript/google-code-prettify/lang-epsilon.js"></script>
        
      
        
          <script src="../../../assets/javascript/google-code-prettify/prettyprint.js"></script>
        
      
        
          <script src="../../../assets/javascript/extra.js"></script>
        
      
        
          <script src="https://w.appzi.io/w.js?token=jlv6W"></script>
        
      
    
  </body>
</html>